//
//  HPFestivalDetailDataSource.m
//  HappyPenguin
//
//  Created by zhuangyihang on 1/12/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HPFestivalDetailDataSource.h"
#import "HPFestivalDetailCell.h"

@interface HPFestivalDetailDataSource()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation HPFestivalDetailDataSource


- (id)initWithTableView:(UITableView *)tableView{
    self = [super init];
    if (self) {
        self.tableView = tableView;
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
    }
    return self;
}

#pragma mark - UITableViewDataSource,UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"HPFestivalDetailCell";
    HPFestivalDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[HPFestivalDetailCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [HPFestivalDetailCell getCellHeight];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 30;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    CGFloat height = [self tableView:tableView heightForHeaderInSection:section];
    
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.width, height)];
    v.backgroundColor = [UIColor colorWithRGB:0xf0f0f0];
    
    UILabel *l = [UILabel new];
    [v addSubview:l];
    [l mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(v);
        make.left.equalTo(v).offset(15);
    }];
    l.textColor = [UIColor blackColor];
    l.text = @"显示5人,共100人";
    return v;
}

@end
